package com.yimi.appstore.download2;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBOpenHelper extends SQLiteOpenHelper {
	private static final String DBNAME = "download.db";
	private static final int VERSION = 1;
	

	public DBOpenHelper(Context context) {
		super(context, DBNAME, null, VERSION);
	}
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE IF NOT EXISTS filedownlog (id integer primary key autoincrement,resource varchar(100),version varchar(50) ,iconurl varchar(100), downpath varchar(100),localpath varchar(100), mediatype varchar(10), threadid INTEGER, downlength INTEGER,totlesize INTEGER)");
		db.execSQL("CREATE TABLE IF NOT EXISTS filedownhistory (id integer primary key autoincrement, resource varchar(100),version varchar(50) ,iconurl varchar(100), downpath varchar(100),localpath varchar(100),mediatype varchar(10), createtime DATETIME , totlesize INTEGER)");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS filedownlog");
		db.execSQL("DROP TABLE IF EXISTS filedownhistory");
		onCreate(db);
	}
}